var express = require('express');
var router = express.Router();

const { addCustomers,getCustomers,getCustomersBySalesmansId,deleteCustomers,sureAlterCustomers,getUsers } = require('../service/customersService')

//新增用户
router.post('/addCustomers', async function (req, res, next) {
    const data = await addCustomers(req.body);
    res.send(data)
});


//获取所有用户
router.get('/getCustomers',async function(req, res, next){
    const data = await getCustomers(req.query);
    res.send(data)
});

//通过销售员Id获取用户
router.get('/getCustomersBySalesmansId',async function(req, res, next){
    const data = await getCustomersBySalesmansId(req.query);
    res.send(data)
});

//删除用户
router.post('/delCustomersById', async function (req, res, next) {
    const data = await deleteCustomers(req.body);
    res.send(data);
});

//通过id获取一个用户
// router.post('/alterCustomersById', async function (req, res, next) {

//     const data = await alterCustomers(req.body);
//     res.send(data);
// });

//修改用户数据
router.post('/sureAlterCustomers', async function (req, res, next) {
    const data = await sureAlterCustomers(req.body);
    res.send(data);
  });


//通过手机号获取用户
router.post('/getOneCustomer', async function(req, res, next) {
    const data = await getUsers(req.body);
    res.send(data)
});
  

module.exports = router;